package cn.edu.fudan.autoparser;

import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class BitAutoHTMLParser extends AutoHTMLParser {
	public BitAutoHTMLParser(String basicURL, String subURL) {
		super(basicURL, subURL);
	}
	private String convertURL(String URL){
		if(URL.lastIndexOf('_')>0){
			return URL.substring(0,URL.lastIndexOf('_'))+"_all.html#p1";
		}else {
			return URL;
		}
	}

	@Override
	public void getHTML() throws IOException {
		Document doc = null;
		doc=Jsoup.connect(basicURl+convertURL(subURL)).get();
		HTML=doc;
	}

	@Override
	public void parseHTML() {
		Elements title=HTML.getElementsByTag("h1");
		Elements content = HTML.getElementsByClass("con_main");//("article-contents");
		this.tiltle=title.get(0).text();
		this.content=content.get(0).text();//HTML.html();
	}

}
